package com.dorm.cj.extension.interceptor;

import org.springframework.http.client.support.InterceptingHttpAccessor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 拦截器
 * preHandle 目标方法执行前执行
 * postHandle 目标方法执行后执行
 * afterCompletion 请求完成时执行
 *
 * 如有权限认证、日志、统计的场景
 *
 * Filter前处理 --> Interceptor前处理 --> controller--> Interceptor后处理 --> Filter后处理
 */
public class TestInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
    }
}
